package com.lagou.service.impl;

import com.lagou.service.HelloService;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName: HelloServiceImpl
 * @Description:
 * @Author: qjc
 * @Date: 2021/10/8 10:24 上午
 */
@Service
public class HelloServiceImpl implements HelloService {
    @Override
    public String sayHello(String name, int timeToWait) {
        int random = new Random().nextInt(timeToWait);
        try {
            Thread.sleep(random);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "hello: " + name;
    }

    @Override
    public String sayGoodBye(String name, int timeToWait) {
        int random = new Random().nextInt(timeToWait);
        try {
            Thread.sleep(random);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "good bye: " + name;
    }

    @Override
    public String sayGoodNight(String name, int timeToWait) {
        int random = new Random().nextInt(timeToWait);
        try {
            Thread.sleep(random);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "good night: " + name;
    }
}
